<?php
//robots管理
class robotsMod extends commonMod {

	public function __construct()
    {
        parent::__construct();
    }

	public function index() {
		$realfile = __ROOTDIR__."/".'robots.txt';
		if(!file_exists($realfile)){
			$this->__mkdirs(dirname($realfile));
			$write=@fopen($realfile,"w");
			@fwrite($write,'');
			@fclose($write);
		}
		$this->robots = file_get_contents($realfile);
		$this->show();  
	}
	public function save() {
		$realfile = __ROOTDIR__."/".'robots.txt';
		$cachedata = $_POST['robots'];
		$write=@fopen($realfile,"w");
		@fwrite($write,$cachedata);
		@fclose($write);
		$this->msg('robots更新成功',0);
	}

	private function __mkdirs($dir, $mode = 0755)
	{
	if (!is_dir($dir)) {
		__mkdirs(dirname($dir), $mode);
		return @mkdir($dir, $mode);
	}
	return true;
	}

	

}